<template>
  <div class="foodDessert">
    <dessert-header/>
    <dessert-logo/>
    <dessert-recommend :list="dessertRecommendList "/>
    <dessert-footer/>
  </div>
</template>

<script>
import DessertHeader from "./components/DessertHeader.vue";
import DessertLogo from "./components/DessertLogo.vue";
import DessertRecommend from "./components/DessertRecommend.vue";
import DessertFooter from "./components/DessertFooter.vue";
import axios from "axios";
export default {
  name: "foodDessert",
  components: {
    DessertHeader,
    DessertLogo,
    DessertRecommend,
    DessertFooter
  },
  data: function() {
    return {
      dessertRecommendList: []
    };
  },
  mounted() {
    this.getHomeApiInfo();
  },
  methods: {
    getHomeApiInfo() {
      axios
        .get("/mock/Food/dessert.json")
        .then(this.getHomeResponseInfo, function(success) {
          console.log("请求json数据成功");
          console.log(success);
        })
        .catch(function(err) {
          console.log("请求json数据失败");
          console.log(err);
        });
    },
    getHomeResponseInfo(response) {
      console.log(response.data);
      let res = response.data;
      if (res.success && res.dataList) {
        const dessertData = res.dataList;
        this.dessertRecommendList = dessertData.DessertRecommedLists;
      }
    }
  }
};
</script>          